<?php

namespace App\Http\Resources;

use App\Traits\BaseResource;
use Illuminate\Http\Resources\Json\Resource;

class Tag extends Resource {
	use BaseResource;

	private function toEdit($request) {
		return $this->filterFields([
			'id' => $this->id,
			'tag_name' => $this->tag_name,
			'status' => $this->status,
		]);
	}

	private function toDefault($request) {
		return $this->filterFields([
			'id' => $this->id,
			'tag_name' => $this->tag_name,
			'status' => $this->status,
			'item_nums' => $this->whenLoaded('items', function () {
				return $this->items->count();
			}),
			'created_at' => $this->created_at,
			'updated_at' => $this->updated_at,
		]);
	}
}
